/**
 * @Package: 	com.group.JavaBean 
 * @author: 	Liu  
 * @date: 		Dec 27, 2018 8:19:25 AM 
 */
package com.group.JavaBean;

import com.group.DAO.GUserDAO;

/**
 * @ClassName:	 GUser.java
 * @Description: 用户类
 * @author:		 Liu
 * @date: 		 Dec 27, 2018 8:19:25 AM 
 */
public class GUser {
	// @Fields userID : 登录ID(学生学号/教师工号)
	String userID;
	// @Fields userPwd : 密码
	String userPwd;

	//构造方法
	public GUser() {};
	public GUser(String userID, String password) {
		this.userID = userID;
		this.userPwd = password;
	}
	
	//用户登录
	public boolean login() {
		GUserDAO dao = new GUserDAO();
		//存在账号
		if(dao.login(this.userID, this.userPwd))	return true;
		return false;
	}
	
	/**
	 * @Function: 	 GUser.java
	 * @Description: 判断登陆用户是否为老师
	 * @param:		   用户ID
	 * @return:		 (老师[teacher]/学生[null])
	 * @author: 	 Liu
	 * @date:		 Dec 29, 2018 9:35:12 AM 
	 */
	public String isTeacher(String userID) {
		String flag = "teacher";
		if(userID.length() == 12) flag = null;
		return flag;
	}
	
	/**
	 * @Function: 	 GUser.java
	 * @Description: 获取用户名                       
	 * @param:		  用户类                        
	 * @return:		   用户名                       
	 * @author: 	 Liu
	 * @date:		 Jan 2, 2019 11:47:13 AM 
	 */
	public String getNameByID(GUser user) {
		GUserDAO dao = new GUserDAO();
		return dao.getNameByID(user);
	}
	
	//get&set
	public String getUserID() {
		return userID;
	}
	public void setUserID(String userID) {
		this.userID = userID;
	}
	public String getUserPwd() {
		return userPwd;
	}
	public void setUserPwd(String userPwd) {
		this.userPwd = userPwd;
	}
	/**
	 * @Function: 	 GUser.java
	 * @Description: 该函数的功能描述
	 * @param:		   参数
	 * @return:		   返回结果描述
	 * @author: 	 Miss Zheng
	 * @date:		 2019年1月3日 下午8:28:39 
	 */
	public void updatePwd(String userID, String newPwd) {
		// TODO Auto-generated method stub
		GUserDAO dao = new GUserDAO();
		dao.updatePwd(userID,newPwd);
	}
}
